package com.gjb6.customer.hxChat;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.gjb6.customer.R;
import com.gjb6.customer.account.ParamKey;
import com.hyphenate.chat.EMMessage;
import com.hyphenate.easeui.EaseConstant;
import com.hyphenate.easeui.ui.EaseChatFragment;
import com.hyphenate.easeui.utils.SPUtils;
import com.hyphenate.easeui.widget.chatrow.EaseCustomChatRowProvider;

/**
 * A simple {@link Fragment} subclass.
 */
public class MyChatFragment extends EaseChatFragment implements EaseChatFragment.EaseChatFragmentHelper{

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view =inflater.inflate(R.layout.ease_fragment_chat, container, false);
        setChatFragmentHelper(this);
        fragmentArgs = getArguments();
        // 判断单聊还是群聊
        chatType = 1;
//        chatType = fragmentArgs.getInt(EaseConstant.EXTRA_CHAT_TYPE,EaseConstant.CHATTYPE_SINGLE);
        // 会话人或群组id
        customerName = fragmentArgs.getString(ParamKey.CUSTOMERNAME);
        customerPortrait = fragmentArgs.getString(ParamKey.CUSTOMERPORTRAIT);
        masterName = fragmentArgs.getString(ParamKey.MASTERNAME);
        masterPortrait = fragmentArgs.getString(ParamKey.MASTERPORTRAIT);
        toChatUsername = fragmentArgs.getString(EaseConstant.EXTRA_USER_ID);
        SPUtils.put(getActivity(), ParamKey.CUSTOMERNAME,customerName);
        SPUtils.put(getActivity(), ParamKey.CUSTOMERPORTRAIT,customerPortrait);
        SPUtils.put(getActivity(), ParamKey.MASTERNAME,masterName);
        SPUtils.put(getActivity(), ParamKey.MASTERPORTRAIT,masterPortrait);
        return view;
    }


    @Override
    public void onSetMessageAttributes(EMMessage message) {
        message.setAttribute("customerName", customerName);
        message.setAttribute("customerPortrait", customerPortrait);
    }

    @Override
    public void onEnterToChatDetails() {

    }

    @Override
    public void onAvatarClick(String username) {

    }

    @Override
    public void onAvatarLongClick(String username) {

    }

    @Override
    public boolean onMessageBubbleClick(EMMessage message) {
        return false;
    }

    @Override
    public void onMessageBubbleLongClick(EMMessage message) {

    }

    @Override
    public boolean onExtendMenuItemClick(int itemId, View view) {
        return false;
    }

    @Override
    public EaseCustomChatRowProvider onSetCustomChatRowProvider() {
        return null;
    }
}
